package gspushmq.util;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import gspushmq.model.ApiMessageType;
import gspushmq.model.DataBase;
import gspushmq.v1.produce.GGDataStorage;

/**
 *
 * 需要同步的的方法法
 * @version 1.0
 * @since JDK1.7
 * @author yutao
 * @company 上海朝阳永续信息技术有限公司
 * @copyright (c) 2016 SunTime Co'Ltd Inc.All rights reserved.
 * @date 2019年1月2日下午5:28:48
 */
public class SynUtil {

	
	public static Map<String, Object> synApiCommon(ApiMessageType apiType) {
		
		DataBase dataBase = GGDataStorage.ApiBaseMap.get(apiType);
		if(dataBase == null) {
			dataBase = new DataBase();
			GGDataStorage.ApiBaseMap.put(apiType, dataBase);
		}
		ConcurrentHashMap<String, Object> baseAidMap = dataBase.getAccountIdsMap();
		if(baseAidMap == null) {
			baseAidMap = new ConcurrentHashMap<>();
			dataBase.setAccountIdsMap(baseAidMap);
		}
		return baseAidMap;
	}
}
